const { handleStar } = require("../../utils/Star")
Page({
  data: {
    
  },
  onSubmit(event) {
    var keyword = event.detail.value.name
    console.log(keyword)
    var url = `http://47.108.197.28:4000/api/search?keyword=${keyword}`
    wx.request({
      url,
      header: {'content-type':'application/json'},
      method: 'GET',
      dataType: 'json',
      responseType: 'text',
      success: (res)=>{
        var movie = []
        console.log(res)
        var res = res.data.res
        res.forEach(item => {
          var { title, pic, raiting, slogo } = item;
          var star = raiting
          movie.push({
            title,
            pic,
            raiting,
            slogo,
            star: handleStar(star)
          })
        })
        this.setData({
          movie
        })
        
      },
    });
  }
})